#!/bin/bash
# MUST be executed at the wpp ROOT dir.
# e.g. $cd /path/to/wpp; ./wpp/util/src_lines

sum_py=0
pyfiles=`find . -name '*.py'`
echo '----------python------------'
for pyfile in $pyfiles
do
    l=`wc -l $pyfile| awk '{print $1}'` 
    printf "%-40s%5d\n" $pyfile $l
    sum_py=$(($sum_py+$l)) 
done

sum_bash=0
bashfiles=`grep -nr '#!/bin/bash' . |grep -v grep  |grep -v '\.hg' |grep -v '\.swp'| awk -F: '{print $1}'`
echo '----------bash------------'
for bashfile in $bashfiles
do
    l=`wc -l $bashfile| awk '{print $1}'` 
    printf "%-40s%5d\n" $bashfile $l
    sum_bash=$(($sum_bash+$l)) 
done

echo '-----------Results------------'
printf "%-20s%10d\n" "Python files:" $sum_py
printf "%-20s%10d\n" "Bash files:" $sum_bash
printf "%-20s%10d\n" "Total lines:" $(($sum_bash+$sum_py))
